<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商家审核</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="../css/style.css">
	<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
    
</head>

<body class="hold-transition skin-red sidebar-mini"  >
  <!-- .box-body -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">商家审核</h3>
                    </div>

                    <div class="box-body">

                        <!-- 数据表格 -->
                        <div class="table-box">

                            <!--工具栏-->
                            
                            <div class="box-tools pull-right">
                                <div class="has-feedback">
							        公司名称：<input  id="name">
									店铺名称： <input  id="sName">
									<button class="btn btn-default" onclick="listSeller()">查询</button>
                                </div>
                            </div>
                            <!--工具栏/-->

			                  <!--数据列表-->
			                  <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
			                      <thead>
			                          <tr>
			                              <th class="" style="padding-right:0px">
			                                  <input id="selall" type="checkbox" class="icheckbox_square-blue">
			                              </th> 
										  <th class="sorting_asc">商家ID</th>
									      <th class="sorting">公司名称</th>
									      <th class="sorting">店铺名称</th>
									      <th class="sorting">联系人姓名</th>
									      <th class="sorting">公司电话</th>
									     							
					                      <th class="text-center">操作</th>
			                          </tr>
			                      </thead>
			                      <tbody id="sellerShow">

			                      </tbody>
			                  </table>
			                  <!--数据列表/-->
							<form id="page">

								<a href="javascript:toPage(1)">首页</a>
								<a href="javascript:toPage(2)">上一页</a>
								第<input type="text"  id="pageNum" size="1px" readonly="readonly">页/
								共<input type="text" id="pages" size="1px" disabled="disabled">页/
								共<input type="text" id="total" size="1px" disabled="disabled">条
								<a href="javascript:toPage(3)">下一页</a>
								<a href="javascript:toPage(4)">尾页</a>
							</form>
							  
							 
                        </div>
                        <!-- 数据表格 /-->
                        
                        
                        
                        
                     </div>
                    <!-- /.box-body -->
                    
	          
					    
                                
<!-- 商家详情 -->
<div class="modal fade" id="sellerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" >
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="myModalLabel">商家详情</h3>
		</div>
		<div class="modal-body">							
			
			 <ul class="nav nav-tabs">
			  <li class="active"><a href="#home" data-toggle="tab">基本信息</a></li>
			  <li><a href="#linkman" data-toggle="tab">联系人</a></li>
			  <li><a href="#certificate" data-toggle="tab">证件</a></li>
			  <li><a href="#ceo" data-toggle="tab">法定代表人</a></li>
			  <li><a href="#bank" data-toggle="tab">开户行</a></li>
			</ul>							
			
			<!-- 选项卡开始 -->
		    <div id="myTabContent" class="tab-content">

           <!-- 选项卡结束 -->
		</div>
		</div>
		</div>
		<div class="modal-footer">						
			<button class="btn btn-success" data-dismiss="modal" aria-hidden="true" onclick="auditYes()">审核通过</button>
         	<button class="btn btn-danger"  data-dismiss="modal" aria-hidden="true" onclick="auditNo()">审核未通过</button>
            <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true" onclick="auditKill()">关闭商家</button>
			<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
		</div>
	  </div>
	</div>
</div>


</body>
<script>
	$(function (){
		listSeller()
	})
	function listSeller(p){
		$.ajax({
			url: "/sel/listSeller",
			data: {name:$("#name").val(),sName:$("#sName").val(),pageNum:p},
			type: "get",
			dataType: "json",
			async: false,
			success: function (result) {
				var html = ""
				if (result.code == "666") {
					var sels = result.data.rows
					for (var i = 0; i < sels.length ; i++) {
						html += '<tr>'
						html += '<td><input type="checkbox"></td>'
						html += '<td>'+ sels[i].sellerId +'</td>'
						html += '<td>'+ sels[i].name +'</td>'
						html += '<td>'+ sels[i].nickName +'</td>'
						html += '<td>'+ sels[i].linkmanName +'</td>'
						html += '<td>'+ sels[i].telephone +'</td>'
						html += '<td className="text-center">'
						html += '<button type="button" className="btn bg-olive btn-xs" data-toggle="modal" onclick="selectById('+"'" + sels[i].sellerId + "'"+')" data-target="#sellerModal">详情 </button>'
						html += '</td>'
						html += '</tr>'
					}
					$("#sellerShow").html(html)
					// 分页
					$("#pageNum").val(result.data.pageNum);
					$("#pages").val(result.data.pages);
					$("#total").val(result.data.total);
				} else {
					alert(result.message)
				}

			}
		})
	}
	function selectById(sellerId){
		$.ajax({
			url: "/sel/selectById",
			data: {id: sellerId},
			type: "get",
			dataType: "json",
			async: false,
			success: function (result) {
				var html = ""
				if (result.code == "666") {
					var s = result.data
					html += '<div class="tab-pane active in" id="home">'
					html += '<br>'
					html += '<table class="table table-bordered table-striped"  width="800px">'
					html += '<tr>'
					html += '<td>公司名称</td>'
					html += '<td>'+ s.name +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>公司手机</td>'
					html += '<td>'+ s.telephone +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>公司电话</td>'
					html += '<td>'+ s.telephone +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>公司详细地址</td>'
					html += '<td>'+ s.addressDetail +'</td>'
					html += '</tr>'
					html += '</table>'
					html += '</div>'
					html += '<div class="tab-pane fade" id="linkman">'
					html += '<br>'
					html += '<table class="table table-bordered table-striped" >'
					html += '<tr>'
					html += '<td>联系人姓名</td>'
					html += '<td>'+ s.linkmanName +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>联系人QQ</td>'
					html += '<td>'+ s.linkmanQq +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>联系人手机</td>'
					html += '<td>'+ s.linkmanMobile +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>联系人E-Mail</td>'
					html += '<td>'+ s.linkmanEmail +'</td>'
					html += '</tr>'
					html += '</table>'
					html += '</div>'
					html += '<div class="tab-pane fade" id="certificate">'
					html += '<br>'
					html += '<table class="table table-bordered table-striped" >'
					html += '<tr>'
					html += '<td>营业执照号</td>'
					html += '<td>'+ s.licenseNumber +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>税务登记证号</td>'
					html += '<td>'+ s.taxNumber +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>组织机构代码证号</td>'
					html += '<td>'+ s.orgNumber +'</td>'
					html += '</tr>'
					html += '</table>'
					html += '</div>'
					html += '<div class="tab-pane fade" id="ceo">'
					html += '<br>'
					html += '<table class="table table-bordered table-striped" >'
					html += '<tr>'
					html += '<td>法定代表人</td>'
					html += '<td>'+ s.legalPerson +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>法定代表人身份证号</td>'
					html += '<td>'+ s.legalPersonCardId +'</td>'
					html += '</tr>'
					html += '</table>'
					html += '</div>'
					html += '<div class="tab-pane fade" id="bank">'
					html += '<br>'
					html += '<table class="table table-bordered table-striped" >'
					html += '<tr>'
					html += '<td>开户行名称</td>'
					html += '<td>'+ s.bankName +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>开户行支行</td>'
					html += '<td>'+ s.bankName +'</td>'
					html += '</tr>'
					html += '<tr>'
					html += '<td>银行账号</td>'
					html += '<td>'+ s.bankUser +'</td>'
					html += '</tr>'
					html += '</table>'
					html += '</div>'
					html += '</div>'
					$("#myTabContent").html(html)
				} else{
					alert(result.message)
				}
			}
		})
	}
	function auditYes(){
		$.ajax({
			url: "/sel/auditYes",
			type: "get",
			dataType: "json",
			async: false,
			success: function (result) {
				if (result.code == "666") {
					alert(result.message)
					listSeller()
				} else {
					alert(result.message)
				}
			},
			error: function (){
				alert("系统异常")
			}
		})
	}
	function auditNo(){
		$.ajax({
			url: "/sel/auditNo",
			type: "get",
			dataType: "json",
			async: false,
			success: function (result) {
				if (result.code == "666") {
					alert(result.message)
					listSeller()
				} else {
					alert(result.message)
				}
			},
			error: function (){
				alert("系统异常")
			}
		})
	}
	function auditKill(){
		$.ajax({
			url: "/sel/auditKill",
			type: "get",
			dataType: "json",
			async: false,
			success: function (result) {
				if (result.code == "666") {
					alert(result.message)
					listSeller()
				} else {
					alert(result.message)
				}
			},
			error: function (){
				alert("系统异常")
			}
		})
	}
	//分页
	function toPage(id){
		var num = parseInt($("#pageNum").val());
		var pages = parseInt($("#pages").val());
		var p = num;
		if (id == 1) {
			p = 1;
			$("#pageNum").val(1);
		}
		if (id == 2){
			if (num == 1) {
				alert("已经到达首页了");
				return;
			}
			p = num - 1;
			$("#pageNum").val(num - 1);
		}
		if (id == 3){
			if (num == pages) {
				alert("已经到达尾页了");
				return;
			}
			p = num + 1;
			$("#pageNum").val(num + 1);
		}
		if (id==4){
			p = pages;
			$("#pageNum").val(pages);
		}
		listSeller(p);
	}
</script>
</html>